#include <iostream>
#include <queue>
using namespace std;

const int maxn = 1001;
int value[maxn];
int alice, bob;

struct cmp
{
	operator bool()(int x, int y)
	{
		return x > y;
	}
};

void work(int n, int m)
{
	priority_queue<int, vector<int>, cmp> q;
	for (int i = 0; i < n; ++i) {
		int tmp;
		q.push(tmp);
	}
	int st[2];
	st[0] = st[1] = 0;
	int now = 0;
	for (int i = 0; i < m; ++i) {
		int p, pp;
		cin >> p;
		int target = q.top(), max = 0, sum = 0;
		
		cout << "*********" << target << endl;

		bool cd1 = false, cd2 = false, cd3 = false, cd4 = false;
		if (!p) cd1 = true;
		if (p > 2) cd2 = true;

		for (int j = 0; j < p; ++j) {
			int tmp;
			cin >> tmp;
			if (tmp > max) max = tmp;
		}

		cin >> pp;
		for (int j = 0; j < pp; ++j) {
			int tmp;
			cin >> tmp;
			if (tmp == target) cd4 = true;
			if (tmp) {
				unpoketed[tmp - 1] = false;
				sum += tmp b;
			}
			if (!tmp) cd3 = true;
		}

		if (!cd4) cd2 = true;
		if (cd1) {
			now = 1 - now;
			st[now] += min;
		} else
		if (cd3) {
			now = 1 - now;
			st[now] += max;
		} else
		if (cd2) {
			now = 1 - now;
			st[now] += max;
		} else st[now] += sum;

	}
	alice = st[0];
	bob = st[1];
}

int main()
{
	int n, m;
	while (cin >> n >> m) {
		work(n, m);
		cout << alice << " : " << bob;
	}
	return 0;
}

